// 搜索 api https://autumnfish.cn/search get parms keywords
// 封面 api https://autumnfish.cn//song/detail

var app = new Vue({
    el : "#player",
    data:{
        query:"五月天",
        musicList:[],
        musicUrl:"",
        musicPicUrl:"",
        mvUrl:"",
        hotComments:[],
        isPlaying:false,
        //mv遮罩层
        isShow:false,
    },
    methods:{
        searchMusic:function(){
            var that = this;
            axios.get("https://autumnfish.cn/search?keywords="+this.query)
                .then(function(response){
                    // console.log(response);
                    that.musicList = response.data.result.songs;
                },function(err){
                    console.log(err);
                })
        },
        playMusic: function(musicId){
            var that = this;
            axios.get("https://autumnfish.cn/song/url?id="+musicId)
                .then(function(response){
                    that.musicUrl = response.data.data[0].url;
                },function(err){});
            //获取歌曲详情
            axios.get("https://autumnfish.cn/song/detail?ids="+musicId)
                .then(function(response){
                    // console.log(response.data.songs[0].al.picUrl);
                    that.musicPicUrl = response.data.songs[0].al.picUrl;
                },function(err){});
            //歌曲评论获取
            axios.get('https://autumnfish.cn/comment/hot?type=0&id='+musicId)
            .then(function(response){
                console.log(response.data.hotComments);
                that.hotComments = response.data.hotComments;
            },function(err){});
        },
        play:function(){
            console.log("playing");
        },
        pause:function(){
            console.log("pause");
        },
        playMV:function(mvid){
            var that = this;
            axios.get("https://autumnfish.cn/mv/url?id="+mvid)
                .then(function(response){
                    console.log(response.data.data.url);
                    that.mvUrl = response.data.data.url;
                    that.isShow= true;
                },function(err){})
        },
        quitMV:function(){
            var that = this;
            that.isShow = false;
            that.mvUrl = " ";
        },
 
            
    }
});